package com.lambert.ginkgo.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

/**
 * Represents a chat completion response returned by model, based on the provided
 * input.
 *
 * @param id A unique identifier for the chat completion.
 * @param choices A list of chat completion choices. Can be more than one if n is
 * greater than 1.
 * @param created The Unix timestamp (in seconds) of when the chat completion was
 * created.
 * @param model The model used for the chat completion.
 * @param systemFingerprint This fingerprint represents the backend configuration that
 * the model runs with. Can be used in conjunction with the seed request parameter to
 * understand when backend changes have been made that might impact determinism.
 * @param object The object type, which is always chat.completion.
 * @param usage Usage statistics for the completion request.
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public record OpenAIResponse(// @formatter:off
                             @JsonProperty("id") String id,
                             @JsonProperty("choices") List<Choice> choices,
                             @JsonProperty("created") Long created,
                             @JsonProperty("model") String model,
                             @JsonProperty("system_fingerprint") String systemFingerprint,
                             @JsonProperty("object") String object,
                             @JsonProperty("usage") Usage usage
) { // @formatter:on

    /**
     * Chat completion choice.
     *
     * @param finishReason The reason the model stopped generating tokens.
     * @param index The index of the choice in the list of choices.
     * @param message A chat completion message generated by the model.
     * @param logprobs Log probability information for the choice.
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonIgnoreProperties(ignoreUnknown = true)
    public record Choice(// @formatter:off
                         @JsonProperty("finish_reason") ChatCompletionFinishReason finishReason,
                         @JsonProperty("index") Integer index,
                         @JsonProperty("message") ChatCompletionMessage message,
                         @JsonProperty("logprobs") LogProbs logprobs) { // @formatter:on
    }

	}

